/*
 * @Author: wang cong wangc9832@163.com
 * @Date: 2023-06-02 20:39:55
 * @LastEditors: wang cong wangc9832@163.com
 * @LastEditTime: 2024-02-19 11:08:24
 * @FilePath: /ams_kt_front/src/api/operation/amsContractLeasedManage.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsContractLeased';
// 根据变更记录DTO生成应收计划
export const getByChangeRecordLeased = (params?: any) =>
  defHttp.post({ url: api + '/getByChangeRecordLeased', params });
// 根据租赁合同生成应收计划
export const getByContract = (params?: any) =>
  defHttp.post({ url: api + '/getByContract', params });
// 审批
export const approved = (id?: any) =>
  defHttp.post({ url: api + '/approved/' + id });
// 驳回
export const reject = (id?: any) =>
  defHttp.post({ url: api + '/reject/' + id });
// 租赁合同_变更版本前进行校验
export const checkChangeVersions = (id?: any) =>
  defHttp.get({ url: api + '/checkChangeVersions/' + id });

// 合同弃审
export const unapproved = (id?: any) =>
  defHttp.post<BasicFetchResult<any>>({
    url: api + '/unapproved/' + id,
  });

// 预警合同_分页查询
export const warningPage = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: api + '/warningPage',
    params,
  });
// 租赁合同主要信息_暂存修改
export const stagingEdit = (params?: any) =>
  defHttp.post({ url: api + '/stagingEdit', params });
// 租赁合同_变更版本
export const updateVersions = (params?: any) =>
  defHttp.post({ url: api + '/updateVersions', params });
//租赁合同主要信息_暂存
export const staging = (params?: any) =>
  defHttp.post({ url: api + '/staging', params });
// 根据租赁资源ID_分页查询合同
export const pageByLeasedAssetId = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: api + '/pageByLeasedAssetId',
    params,
  });
// 根据资产ID_分页查询合同
export const pageByAssetId = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/pageByAssetId', params });
//非正常解约
export const abnormalOff = (params?: any) =>
  defHttp.post({ url: api + '/abnormalOff', params });
//租赁合同历史版本_单条查询
export const detailHistory = (id?: any) =>
  defHttp.get<BasicFetchResult<any>>({
    url: '/amsContractLeasedV/detail/' + id,
  });
// 租赁合同_变更业务员(负责人)
export const changeLeasedPrincipal = (params?: any) =>
  defHttp.post({ url: api + '/changeLeasedPrincipal', params });
// 租赁合同_退租
export const offLease = (params?: any) =>
  defHttp.post({ url: api + '/offLease', params });

// 查单条
export const detail = (id?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/detail/' + id });
/**
 * 查询租赁合同主要信息分页
 * @author Modesto
 * @date 2023-06-02 19:20:26
 */
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page', params });
/**
 * 查询租赁合同主要信息不分页
 * @author Modesto
 * @date 2023-06-02 19:20:26
 */
export const list = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });
/**
 * 添加租赁合同主要信息
 * @author Modesto
 * @date 2023-06-02 19:20:26
 */
export const add = (params?: any) =>
  defHttp.post({ url: api + '/add', params });
/**
 * 修改租赁合同主要信息
 * @author Modesto
 * @date 2023-06-02 19:20:26
 */
export const edit = (params?: any) =>
  defHttp.post({ url: api + '/edit', params });

/**
 * 删除租赁合同主要信息
 * @author Modesto
 * @date 2023-06-02 19:20:26
 */
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
/**
 * 导出租赁合同主要信息
 * @author Modesto
 * @date 2023-06-02 19:20:26
 */
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true },
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};
